/**
 * @author joshua
 */
joshua.util.FormaPagoForm=Ext.extend(Ext.Window,{
	title:'Especifique forma de pago',
	iconCls: 'money_edit',
    layout: 'fit',
    width: 390,
	height:120,
    modal:true,								  
    maximizable:false,
    draggable:false,
    resizable:false,
    closeAction:'hide',
    plain:true,
	id_envio:'',
	success:null,
	initComponent:function(){

		this.form= new Ext.form.FormPanel({
	        width: 450,
	        frame: true,					       
	        labelWidth: 90,
	        defaults: {
	            anchor: '91%',
	            allowBlank: false,
	            msgTarget: 'side'
	        },
	        items: [{
                xtype:'combo',
				fieldLabel: 'Forma pago',
				name: 'txt_fpago',
				store: [
					['Efectivo', 'Efectivo'], 
					['Cheque', 'Cheque'],
					['Tarjeta de credito', 'Tarjeta de credito'], 
					['Money Order', 'Money Order'],
					['Deposito Bancario', 'Deposito Bancario'], 
					['Reposicion', 'Reposicion'],
					['Cortesia', 'Cortesia'], 
					['Otro', 'Otro']
				],
				emptyText:'Efectivo? Cheque?...',
				typeAhead: true,
				triggerAction: 'all',
				selectOnFocus: true,
				allowBlank: false,
				editable: false,
                anchor:'98%'
           	 }]
		});

		var config={
			items:this.form,
			buttons:[{
				text:'<b>Guardar</b>',	
				iconCls:'save',
				scope:this,
				handler: function(){
					this.guardarForm();
				}
			},{
				text:'<b>Cancelar</b>',
				iconCls:'delete',
				scope:this,
				handler:function(){
					this.hide();
				}
			}]
		};//fin config

		Ext.apply(this,Ext.apply(this.initialConfig,config));		
			
		joshua.util.FormaPagoForm.superclass.initComponent.apply(this,arguments);
 	},
 	
 	onRender:function(){
 		joshua.util.FormaPagoForm.superclass.onRender.apply(this,arguments);
 	},
 	
	guardarForm:function(o){
		//establecemos el md5
		
		if (this.form.getForm().isValid()) {
			var w=this;
			this.form.getForm().submit({
				url:"Servicios/s.php",
				scope:this,
				params:{
					cmd:'entregar',
					className:'Envio',
					txtId:this.id_envio//,
					//comboEmpresa:this.comboEmpresa.getValue()
				},
				success: function(fp, o){
					this.success();
	            }, 
				waitMsg:'Guardando...'
			});
		}else
			joshua.funciones.alert('aviso','Aviso',"Faltan datos por completar o algunos no son validos");
	
 	}
});
